<script setup>
import SelectTable from "@/views/lims/contractAnalysis/table/selectTable.vue";
import {ref, toRefs} from "vue";
// const emit = defineEmits(['update:modelValue'])
const props = defineProps(['title','placeholder', 'sql', 'columns', 'valueFiled'])

const selectTable = ref()
const handleSelect = () => {
  console.log('colums is :::', props.columns)
  if (props.columns){
    selectTable.value.selectBySql(props.sql, props.columns)
  }
}
const inputValue = ref('')
const onSelected = (row) => {
  console.log('row is :::', row, props.valueFiled, row[props.valueFiled])
  inputValue.value = row[props.valueFiled]
  // props.modelValue = row[props.valueFiled]
  // emit('update:modelValue', row[props.valueFiled])
}

const onOk = (selectRow) => {

}
</script>

<template>
  <el-input v-model="inputValue" :placeholder="placeholder">
    <template #append>
      <el-button icon="Search" @click="handleSelect"></el-button>
    </template>
  </el-input>
  <select-table ref="selectTable" :title="title" db-type="sqlserver" source="sql" @ok="onSelected"></select-table>
</template>

<style scoped lang="scss">

</style>